From 170c8e5f197b9cf5bf18c3ef7184d8b3bc8406ec Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 1 Jun 2024 19:45:57 +0300 Subject: [PATCH] luci-app-acme: show button "Install package acme-acmesh-dnsapi" if DNS mode is used Signed-off-by: Sergey Ponomarev --- .../htdocs/luci-static/resources/view/acme.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js b/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js index 07cac56416..937a931269 100644 --- a/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js +++ b/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js @@ -18,6 +18,7 @@ return view.extend({ return certs; }), L.resolveDefault(fs.exec_direct('/usr/libexec/acmesh-dnsinfo.sh'), ''), + L.resolveDefault(fs.stat('/usr/lib/acme/client/dnsapi'), null), ]); }, @@ -25,7 +26,7 @@ return view.extend({ let certs = data[0]; let dnsApiInfoText = data[1]; let apiInfos = dnsapi.parseFile(dnsApiInfoText); - + let hasDnsApi = data[2] != null; let wikiUrl = 'https://github.com/acmesh-official/acme.sh/wiki/'; let wikiInstructionUrl = wikiUrl + 'dnsapi'; let m, s, o; @@ -78,6 +79,19 @@ return view.extend({ o.value('dns', _('DNS')); o.default = 'standalone'; + if (!hasDnsApi) { + let dnsApiPkg = 'acme-acmesh-dnsapi'; + o = s.taboption('general', form.Button, '_install'); + o.depends('validation_method', 'dns'); + o.title = _('Package is not installed'); + o.inputtitle = _('Install package %s').format(dnsApiPkg); + o.inputstyle = 'apply'; + o.onclick = function () { + let link = L.url('admin/system/package-manager') + '?query=' + dnsApiPkg; + window.open(link, '_blank', 'noopener'); + }; + } + o = s.taboption('general', form.DynamicList, "domains", _("Domain names"), _("Domain names to include in the certificate. " + "The first name will be the subject name, subsequent names will be alt names. " + -- 2.30.2